package cn.tedu.seri;

import java.io.Serializable;

/*本类用于封装学生类,用作测试序列化的物料类*/
/*如果本类的对象想要被序列化输出,那么本类必须实现可序列化接口,否则会报错
* 报错信息:java.io.NoSerializableException:cn.tedu.seri.Student
* Serializable接口是一个空接口,里面一个方法也没有,作用是当做标志,标志这个类可以被序列化*/
public class Student implements Serializable {

    //1,定义学生相关的属性+private封装
    private String name;
    private int age;
    private  String addr;
    private char gender;
    public Student(){
        System.out.println("我是Student类的无参构造");
    }

    public Student(String name, int age, String addr, char gender) {
        super();//Object的无参构造
        this.name = name;
        this.age = age;
        this.addr = addr;
        this.gender = gender;
        System.out.println("我是Student类的全参构造");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", addr='" + addr + '\'' +
                ", gender=" + gender +
                '}';
    }
}
